package com.zzu.wardrobe.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.zzu.wardrobe.dao.UserDAO;
import com.zzu.wardrobe.entity.User;

public class UserDAOImpl implements UserDAO {
	private HibernateTemplate hibernateTemplate;
	private User user;
	
	
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}


	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}


	@Override
	public int finduser(User user) {
		// TODO Auto-generated method stub
		String hql = "from User where username = ? and password = ? ";
		List<User> list = hibernateTemplate.find(hql,user.getUsername(),user.getPassword());
		if(list.size() > 0)
			return 1;
		return 0;
	}
	
}
